import wepy from 'wepy'

export default class extends wepy.mixin {
    data = {
        swiper:[],
        // 分类导航
        cates:[],
        // 楼层数据
        floorData:[]
      }
  
      config = {
      }
  
      methods = {
        // 跳转到商品列表
        goGoodsList(url){
         wepy.navigateTo({url})
        }
      }
      // 获取首页轮播图
      async getSwiper(){
        const {data:res}=await wepy.get('/home/swiperdata')
        if(res.meta.status!=200) return wepy.baseToast()
        this.swiper=res.message
        this.$apply()
      }
      // 获取首页分类选项
      async getCates(){
        const {data:res}=await wepy.get('/home/catitems')
        if(res.meta.status!=200) return wepy.baseToast()
        this.cates=res.message
        this.$apply()
      }
      // 获取楼层数据
      async getFloorData(){
        const {data:res}=await wepy.get('/home/floordata')
        if(res.meta.status!=200) return wepy.baseToast()
        this.floorData=res.message
        this.$apply()
      }
      onLoad(){
        this.getSwiper()
        this.getCates()
        this.getFloorData()
      }
}